//
//  BaseTabBar.m
//  ArtDog
//
//  Created by dllo on 16/8/31.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "BaseTabBar.h"
#import "HLMacro.h"
#import "UIImage+Common.h"

@implementation BaseTabBar

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.items = [self setupItems];
        [self setupTabBar];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.items = [self setupItems];
        [self setupTabBar];
    }
    return self;
}

//self.viewControllers = [self setupViewControllers];
//[self setupTabBar];
//[[NSUserDefaults standardUserDefaults]setObject:@{@"id": @"0", @"token": @"df68e038-143e-41cb-b554-456f78f184fc"} forKey:kUserDefaultPathKey];
//}
//
- (NSArray<UITabBarItem *> *)setupItems
{
    NSMutableArray *items = [NSMutableArray array];
    // 设置首页
//    HomeMainViewController *homeMainVC = [[HomeMainViewController alloc]initWithNibName:@"HomeMainViewController" bundle:[NSBundle mainBundle]];
//    HomeNavigationController *homeNav = [[HomeNavigationController alloc]initWithRootViewController:homeMainVC];
    UITabBarItem *homeBarItem = [[UITabBarItem alloc]initWithTitle:@"首页" image:[[UIImage imageNamed:@"icon_home"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"icon_home_selected"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [items addObject:homeBarItem];
    
    // 设置社区页
//    CommunityMainViewController *communityMainVC = [[CommunityMainViewController alloc]initWithNibName:@"CommunityMainViewController" bundle:[NSBundle mainBundle]];
//    CommunityNavigationController *communityNav = [[CommunityNavigationController alloc]initWithRootViewController:communityMainVC];
    UITabBarItem *communityBarItem = [[UITabBarItem alloc]initWithTitle:@"社区" image:[[UIImage imageNamed:@"icon_community"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[UIImage imageNamed:@"icon_community_selected"]];
    [items addObject:communityBarItem];
    
    // 设置商城页
//    StoreMainViewController *storeMainVC = [[StoreMainViewController alloc]initWithNibName:@"StoreMainViewController" bundle:[NSBundle mainBundle]];
//    StoreNavigationController *storeNav = [[StoreNavigationController alloc]initWithRootViewController:storeMainVC];
    UITabBarItem *StoreBarItem = [[UITabBarItem alloc]initWithTitle:@"商城" image:[[UIImage imageNamed:@"icon_store"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"icon_store_selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [items addObject:StoreBarItem];
    
    // 设置我的页
//    MineMainViewController *mineMainVC = [[MineMainViewController alloc]initWithNibName:@"MineMainViewController" bundle:[NSBundle mainBundle]];
//    MineNavigationController *mineNav = [[MineNavigationController alloc]initWithRootViewController:mineMainVC];
    UITabBarItem *mineBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:[[UIImage imageNamed:@"icon_mine"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"icon_mine_selected"]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [items addObject:mineBarItem];
    return items;
}

- (void)setupTabBar
{
    self.barTintColor = [UIColor clearColor];
    self.tintColor = [UIColor blackColor];
    self.backgroundImage = [UIImage new];
    self.shadowImage = [UIImage shadowImageWithWidth:SCREEN_WIDTH];
}


@end
